package com.ktwlsoft.archivemanage.controller;

import com.ktwlsoft.archivemanage.domain.business.businessService.MyInformationService;
import com.ktwlsoft.archivemanage.payload.Result;
import com.ktwlsoft.archivemanage.payload.ResultType;
import com.ktwlsoft.archivemanage.payload.archiveUnit.ArchiveUnitModifyRequest;
import com.ktwlsoft.archivemanage.payload.inforConst.InfrastructureModifyRequest;
import com.ktwlsoft.archivemanage.payload.basic.ResetPasswordRequest;
import com.ktwlsoft.archivemanage.payload.unitMember.UnitMemberModifyRequest;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * 我的
 *
 * @author zhuhe on 2019-07-17 11:07:06
 * @version 1.0
 */
@Api(value = "我的", description = "我的")
@RestController
@RequestMapping("myInformation")
public class MyInformationController {

    /**
     * 我的
     */
    private final MyInformationService myInformationService;

    public MyInformationController(MyInformationService myInformationService) {
        this.myInformationService = myInformationService;
    }

    /**
     * 我的详情 on 2019/10/24 17:02
     *
     * @param id id
     * @return ResponseEntity<?>
     */
    @ApiOperation(value = "我的详情", httpMethod = "GET", produces = "application/json", response = ResponseEntity.class)
    @ResponseBody
    @GetMapping(value = "myInformationDetail")
    public ResponseEntity<?> myInformationDetail(@ApiParam(name = "id", value = "立档单位id") @RequestParam(defaultValue = "", required = true) Long id) {
        return ResponseEntity.ok(myInformationService.myInformationDetail(id));
    }

    /**
     * 重置密码 on 2019/10/24 17:02
     *
     * @param request request
     * @return ResponseEntity<?>
     */
    @ApiOperation(value = "重置密码", httpMethod = "POST", produces = "application/json", response = ResponseEntity.class)
    @ResponseBody
    @PostMapping(value = "resetPassword")
    public ResponseEntity<?> resetPassword(@Valid @RequestBody ResetPasswordRequest request) {
        return ResponseEntity.ok(myInformationService.resetPassword(request));
    }



    /**
     * 单位情况修改 on 2019/10/24 17:02
     *
     * @param request request
     * @return ResponseEntity<?>
     */
    @ApiOperation(value = "单位情况修改", httpMethod = "POST", produces = "application/json", response = ResponseEntity.class)
    @ResponseBody
    @PostMapping(value = "archiveUnitModify")
    public ResponseEntity<?> archiveUnitModify(@Valid @RequestBody ArchiveUnitModifyRequest request) {
        return ResponseEntity.ok(myInformationService.archiveUnitModify(request));
    }

    /**
     * 人员信息修改 on 2019/10/24 17:02
     *
     * @param request request
     * @return ResponseEntity<?>
     */
    @ApiOperation(value = "人员信息修改", httpMethod = "POST", produces = "application/json", response = ResponseEntity.class)
    @ResponseBody
    @PostMapping(value = "unitMemberModify")
    public ResponseEntity<?> unitMemberModify(@Valid @RequestBody UnitMemberModifyRequest request) {
        return ResponseEntity.ok(myInformationService.unitMemberModify(request));
    }

    /**
     * 基础设施修改 on 2019/10/24 17:02
     *
     * @param request request
     * @return ResponseEntity<?>
     */
    @ApiOperation(value = "基础设施修改", httpMethod = "POST", produces = "application/json", response = ResponseEntity.class)
    @ResponseBody
    @PostMapping(value = "infrastructureModify")
    public ResponseEntity<?> infrastructureModify(@Valid @RequestBody InfrastructureModifyRequest request) {
        return ResponseEntity.ok(myInformationService.infrastructureModify(request));
    }
}